<template>
  <section class="jumbotron">
    <h3 class="jumbotron-heading">github用户搜索</h3>
    <div>
      <input
        v-model="search"
        type="text"
        placeholder="请输入搜索内容"
        @keyup.enter="searchHandle"
      />&nbsp;<button @click="searchHandle">搜索</button>
    </div>
  </section>
</template>

<script>
import axios from "axios";
export default {
  name: "Header",
  props: ["getHeaderHandle"],
  data() {
    return {
      search: "",
    };
  },
  methods: {
    async searchHandle() {
      this.getHeaderHandle({ isInit: false, isSearch: true });
      const result = await axios.get(
        `https://api.github.com/search/users?q=${this.search}`
      );
      this.getHeaderHandle({ isSearch: false, data: result.data.items });
    },
  },
};
</script>

<style>
</style>